<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

{include file="Login/header" /}

<body class="login" mycollectionplug="bind" style="background-image: url('/static/img/login/login.jpg')">
<div class="login_boder">
<form action="" method="post" id="loginFrom" onkeydown="if(event.keyCode==13)return login_post();" >
<div class="login_padding" id="login_model">
    <div class="login_m" >
        <div class="login_logo"><div style="font-size: 26px;    ">欢迎</div></div>
  <h2>登录名</h2>
  <label>
    <input type="text" name="username" class="txt_input txt_input2" required  value="">
  </label>
  <h2>密码</h2>
  <label>
    <input type="password" name="password" id="userpwd" class="txt_input"  required  value="">
  </label>
    <label>
            <input type="text"  name="code"  class="txt_input"  required style="width: 120px;" value="">
            <img src="{:captcha_src()}" id="verify_img" onclick="refreshVerify()" width="110px"  alt="captcha" />
    </label>
    <label>
        <a class="btn btn-primary "  data-toggle="modal" data-target="#myModal">注册</a>
        <input type="button" class="btn btn-info" name="button" id="dologin" value="登录" style="opacity: 0.7;">
    </label>
  </div>
</form>

<div id="forget_model" class="login_padding" style="display:none">
<br>
   <h1>Forgot password</h1>
   <br>
   <div class="forget_model_h2">(Please enter your registered email below and the system will automatically reset users’ password and send it to user’s registered email address.)</div>
    <label>
    <input type="text" id="usrmail" class="txt_input txt_input2">
   </label>
  <div class="rem_sub">
  <div class="rem_sub_l">
   </div>
    <label>
     <input type="submit" class="sub_buttons" name="button" id="Retrievenow" value="Retrieve now" style="opacity: 0.7;">
     <input type="submit" class="sub_button" name="button" id="doreg" value="Return" style="opacity: 0.7;">　　
    </label>
  </div>
</div>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                        &times;
                    </button>
                    <h4 class="modal-title" id="myModalLabel">
                       注册类型
                    </h4>
                </div>
                <div class="modal-body">
                     <div class="row">
                         <div class="col-sm-2">   <input type="radio" name="types" value="1">个人</div>
                         <div class="col-sm-4">   <input type="radio" name="types" value="2">企业</div>
                     </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭
                    </button>
                    <button type="button" id="regisen" class="btn btn-primary">
                        确定
                    </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
        '

    </div>




    {include file="Login/footer" /}
</div><!--login_boder end-->
</div><!--login_m end-->
 <br> <br>
<script>

    /*$(document).keydown(function(event){
        switch(event.keyCode){
            case 13:return false;
        }
    });*/

    $(document).ready(function(){
        //登录
        $("#dologin").click(function(){
            login_post();
        });
    });
            /*
            var phone = $("input[name='username']");
            var flag = false;
            var message = "";
            var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if(phone.val().length !=11){
                message = "请输入有效的手机号码！";
            }else if(!myreg.test(phone.val())){
                message = "请输入有效的手机号码！";
            }else{
                flag = true;
            }
            if(!flag){
                alert(message);
                phone.val('').force();
                return false;
            }else{}
            var password =   $("input[name='password']");
            if(password.val() == '' || password.val().length < 6){

                alert('账户密码不得少于6位');
                password.focus();
                return false;
            }
            var code =   $("input[name='code']");
            if(code.val() == '' || code.val().length < 4){
                alert('请填写验证码');
                code.focus();
                return false;
            }
            var data = $("#loginFrom").serialize();
            toAjax("{:url('index/doLogin')}",
                data,"GET",
                function(rs){
                    console.log(rs);
                   if(rs.code == 0){
                        window.location =  rs.data.url;
                    }else{
                        console.log(rs.code);
                        alert(rs.message);
                        if( rs.data.url != null){
                            console.log(rs.data.url);
                            window.location = rs.data.url;
                        }
                        //验证码错误时要求自动刷新验证码 code规定为99
                        if(rs.code == 99){
                            refreshVerify();
                        }
                    }
                },false,false,this);
            */
    //登录（为了点击登录按钮和按Enter键都能实现）
    function login_post() {
        var phone = $("input[name='username']");
        var flag = false;
        var message = "";
        var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
        if(phone.val().length !=11){
            message = "请输入有效的手机号码！";
        }else if(!myreg.test(phone.val())){
            message = "请输入有效的手机号码！";
        }else{
            flag = true;
        }
        if(!flag){
            alert(message);
            phone.val('').force();
            return false;
        }else{}

        var password =   $("input[name='password']");
        if(password.val() == '' || password.val().length < 6){
            alert('账户密码不得少于6位');
            password.focus();
            return false;
        }

        var code =   $("input[name='code']");
        if(code.val() == '' || code.val().length < 4){
            alert('请填写验证码');
            code.focus();
            return false;
        }

        var data = $("#loginFrom").serialize();
        toAjax("{:url('index/doLogin')}",data,"GET",
            function(rs){
                console.log(rs);
               if(rs.code == 0){
                    window.location =  rs.data.url;
                }else{
                    console.log(rs.code);
                    alert(rs.message);
                    if( rs.data.url != null){
                        console.log(rs.data.url);
                        window.location = rs.data.url;
                    }
                    //验证码错误时要求自动刷新验证码 code规定为99
                    if(rs.code == 99){
                        refreshVerify();
                    }
                }
            },false,false,this);
    }
    //刷新验证码
    function refreshVerify() {
        var ts = Date.parse(new Date())/1000;
        var img = document.getElementById('verify_img');
        img.src = "/captcha?id="+ts;
    }
    //注册
    $("#regisen").click(function () {
        var type = $("input[name='types']:checked").val();
        if(type==''){
            console.log('未选择类型');
            return;
        }
        var urls = "{:url('index/register')}"+"?type="+type;
        location.href=urls;
    })

</script>
</body>
</html>